<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/settings/validator.sett.php, $Author:  $ */

/** ============================================================
 * Validator config
 *  PhpFox Team
 * @package validator
 * ============================================================ */

//validator's deafults
global $_CONF;

// standart
$_CONF['validator.defs'] = array(
    'email' => array(
        'pattern'=>'/^[0-9a-zA-Z_]([\-.\w]*[0-9a-zA-Z_])*@([0-9a-zA-Z][\-\w]*\.)+[a-zA-Z]{2,}$/',
        //'pattern'=>'/^[0-9a-zA-Z_]([\-.\w]*[0-9a-zA-Z_])*@([0-9a-zA-Z][\-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,}$/',
        'maxlen'=>255,
    ),

    'email_mult'=> array(
    	'pattern' => '/^[A-Za-z_0-9\.\-]+@[A-Za-z0-9\.\-]+\.[A-Za-z]{2,}([\s]{0,}(,|;)[\s]{0,}[A-Za-z_0-9\.\-]+@[A-Za-z0-9\.\-]+\.[A-Za-z]{2,})*$/',
        'maxlen'=>255,
    ),

    'ip' => array(
        'callback' => array('validator_isIp', array('Validator','isIp')),
        'pattern'  => '/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])[.]){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/',
    ),

    'url' => array(
       'pattern' => '/^(?:(ftp|http|https):)?(?:\/\/(?:((?:%[0-9a-f]{2}|[\-a-z0-9_.!~*\'\(\);:&=\+\$,])+)@)?(?:((?:[a-z0-9](?:[\-a-z0-9]*[a-z0-9])?\.)*[a-z](?:[\-a-z0-9]*[a-z0-9])?)|([0-9]{1,3}(?:\.[0-9]{1,3}){3}))(?::([0-9]*))?)?((?:\/(?:%[0-9a-f]{2}|[\-a-z0-9_.!~*\'\(\):@&=\+\$,;])+)+)?\/?(?:\?.*)?$/i',
       'maxlen'=> 255,
       'minlen'=> 11
    ),

    'login' => array(
       'pattern'=>'/^[\w\-\.]+$/',
       'minlen'=>5,
       'maxlen'=>16
    ),
    'name' => array(
        'pattern'=>'/^[\w\-\x'.sprintf('%x',ord("'")).'\s\.,]+$/',
        'maxlen'=>255
    ),
    'city' => array(
        'maxlen'=>100,
        'pattern'=>'/^[\w\-\s\.,\x'.sprintf('%x',ord("'")).']+$/'
    ),
    'zip'  => array(
        'pattern'=>'/^[a-zA-Z\d\-\s]{0,10}$/',
    ),
    'zip_us'  => array(
        'pattern'=>'/^[0-9]{0,20}$/',
    ),
    'zip_canada'  => array(
        'pattern'=>'/^[a-zA-Z\d]{6}$/',
    ),
    'phone'  => array(
        'minlen'=>7,
        'maxlen'=>50,
        'pattern'=>'/^[a-zA-Z\s\d\-\.\(\)\+]+$/',
    ),
    'phone_us'  => array(
        'minlen'=>12,
        'pattern'=>'/^([2-9]\d{2}\-\d{3}\-\d{4}|\([2-9]\d{2}\)\s?\d{3}\-\d{4})$/',
    ),
    'password'  => array(
        'minlen'=>(isset($_CONF['core']['password_min']) ? $_CONF['core']['password_min'] : 4),
        'maxlen'=>(isset($_CONF['core']['password_max']) ? $_CONF['core']['password_max'] : 14),
    ),

    'money' => array(
        'maxlen'=>12,
        'pattern'=>'/^\d+(\.\d\d)?$/',
    ),
    'cvv'  => array(
        'pattern'=>'/^\d{3,4}$/',
    ),
    'ssn'  => array(
        'maxlen' =>11,
        'pattern'=>'/^([\d]{3}-[\d]{2}-[\d]{4})|([\d]{2}-[\d]{7})$/',
    ),
    'integer' => array(
        'maxlen'=>20,
        'pattern'=>'/^\d+$/',
    ),
    'float' => array(
        'maxlen'=>20,
        'pattern'=>'/^\d+(\.\d+)?$/',
    ),
    'date_us' => array(
        'maxlen'=>10,
        'pattern'=>'/^(0[1-9]|1[0-2])\/(0[1-9]|[1-2][0-9]|3[0-1])\/([12]\d)?\d{2}$/'
    ),
    'date_short_us' => array(
        'maxlen'=>10,
        'pattern'=>'/^(0[1-9]|1[0-2])\/([12]\d)?\d{2}$/'
    ),
    'time' => array(
        'maxlen'=>5,
        'pattern'=>'/^([0-1]\d|2[0-3]):([0-5]\d)$/'
    ),
    'time_us' => array(
        'maxlen'=>8,
        'pattern'=>'/^(([0-1]\d|2[0-3]):([0-5]\d)|(([1-9]|1[0-2]):([0-5]\d)\s(AM|PM|am|pm)))$/'
    ),
    'cc_visa' => array(
        'maxlen'=>16,
        'pattern'=>'/^4(\d{12}|\d{15})$/',
    ),
    'cc_master' => array(
        'maxlen'=>16,
        'pattern'=>'/^5[1-5]\d{14}$/',
    ),
    'cc_ae' => array(
        'maxlen'=>15,
        'pattern'=>'/^3[47]\d{13}$/',
    ),
    'cc_discover' => array(
        'maxlen'=>16,
        'pattern'=>'/^6011\d{12}$/',
    ),
    'cc_diners' => array(
        'maxlen'=>14,
        'pattern'=>'/^3(0[0-5]|[68][0-9])\d{11}$/',
    ),
    'cc_jcb' => array(
        'maxlen'=>16,
        'pattern'=>'/^(3\d{4}|2131|1800)\d{11}$/',
    ),
    'cc_enroute' => array(
        'maxlen'=>15,
        'pattern'=>'/^2(014|149)\d{11}$/',
    ),
    'required'  => array(
        'minlen'=>1,
    ),
);

//custom
$_CONF['validator.defs']['file'] = array(
        'pattern'=>'/^\w+\.(jpg|gif|png|jpeg)$/'
    );

$_CONF['validator.defs']['mark'] = array(
        'pattern'=>'/^[1-5]$/'
    );

$_CONF['validator.defs']['review_subject'] = array(
        'minlen'=>1,
        'maxlen'=>255
    );

$_CONF['validator.defs']['article_name'] = array(
        'minlen'=>1,
        'maxlen'=>255
    );
$_CONF['validator.defs']['address'] = array(
        'minlen'=>1,
        'maxlen'=>150
    );
$_CONF['validator.defs']['percent'] = array(
        'min'=>0.01,
        'max'=>100,
        'pattern'=>'/^(0?|[1-9]?[0-9](0)?)(\.[\d]{0,2})?$/',
    );

$_CONF['validator.defs']['website'] = $_CONF['validator.defs']['url'];

// old: 'pattern'=>'/^(http[s]?:\/\/).+$/',
$_CONF['validator.defs']['link'] = $_CONF['validator.defs']['url'];

$_CONF['validator.defs']['ip_mask'] = array(
		'pattern'=>'/^([\d]|\.|\*){1,15}$/',
    );
?>